package org.uni_hi.muus.replace;

import java.util.Hashtable;

public class MatchMaker {

	private static MatchMaker _matchMaker=null;
	
	private Hashtable _matchTable=null;
	
	private MatchMaker(){
		_matchTable=new Hashtable();
		initDefaults();
	}
	
	protected void initDefaults(){
		String[][] defs={{"config","org.uni_hi.muus.replace.impl.ConfigReplace"},{"about","org.uni_hi.muus.replace.impl.AboutReplace"},{"start","org.uni_hi.muus.replace.impl.StartReplace"}};
		for(int i=0;i<defs.length;i++){
			try {
				MuuSReplace o=(MuuSReplace)Class.forName(defs[i][1]).newInstance();
				_matchTable.put(defs[i][0],o);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
	
	protected static MatchMaker getMatchMaker(){
		if(_matchMaker==null){
			_matchMaker=new MatchMaker();
		}
		return _matchMaker;
	}

	public static MuuSReplace getReplaceCommander(String command){
		return (MuuSReplace) getMatchMaker()._matchTable.get(command);
	}
	
	public String toString(){
		return _matchTable.toString();
	}
}
